let submitButton = document.querySelector('#submit');
submitButton.onclick = function() {
    let username = document.querySelector('#username').value;
    let password = document.querySelector('#password').value;
    if (username == "" || password == "") {
        alert("请填写完整！");
        return
    }

    $.ajax({
        type: 'post',
        url: '/register',
        data: {
            username: username,
            password: password
        },

        success: function(body) {
            if (body != null && body.userId > 0) {
                alert("注册成功");
                location.assign('/login.html');
            } else {
                alert("注册失败");
            }
        }
    });
}